class VideoFile < ActiveRecord::Base
  
#  include DRbUndumped
  
  has_one :media, :as => :mediable
  has_attachment :content_type => ['video/x-flv', 'video/mpeg', 'video/wmv', 'video/avi', 'video/x-ms-wmv', 'audio/x-ms-wmv', 'video/mp4', 'video/x-msvideo'], 
    :storage => :file_system,
    :max_size => 50.megabytes

  PROCESSING = 1
  SUCCESS = 2

  validates_as_attachment

  def convert(highdef=false)
    # Get the absolute path to the rails project using File.expand_path, then append the rest of the path
    video_file = File.expand_path(RAILS_ROOT) + "/public" + public_filename
    job_key = MiddleMan.new_worker(:worker => :video_conversion_worker,:job_key => "video"+self.id.to_s)
    worker  = MiddleMan.worker(:video_conversion_worker,job_key)
    worker.do_work({:absolute_path => video_file, :video_id => self.id.to_s, :highdef => highdef })
  end
end
